package com.cloud.picture.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.cloud.picture.api.aliyunai.model.outpainting.CreateOutPaintingTaskResponse;
import com.cloud.picture.model.dto.picture.*;
import com.cloud.picture.model.entity.Picture;
import com.cloud.picture.model.entity.User;
import com.cloud.picture.model.vo.PictureVO;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
* @author win
* @description 针对表【picture(图片)】的数据库操作Service
* @createDate 2025-03-01 10:49:25
*/
public interface PictureService extends IService<Picture> {

    /**
     * 上传图片
     * @param inputSource 输入源
     * @param pictureUploadRequest 上传请求
     * @return 图片信息
     */
    PictureVO uploadPicture(Object inputSource, PictureUploadWithUserRequest pictureUploadRequest);

    /**
     * 将请求转换为查询条件
     * @param pictureQueryRequest 请求
     * @return 查询条件
     */
    QueryWrapper<Picture> getQueryWrapper(PictureQueryRequest pictureQueryRequest);

    /**
     * 获取图片视图对象
     * @param picture 图片
     * @param request 请求
     * @return 图片视图对象
     */
    PictureVO getPictureVO(Picture picture, HttpServletRequest request);

    /**
     * 分页获取图片封装类
     * @param picturePage 图片分页
     * @param request 请求
     * @return 图片视图分页
     */
    Page<PictureVO> getPictureVoPage(Page<Picture> picturePage, HttpServletRequest request);

    /**
     * 更新修改时对图片进行规则校验
     */
    void validPicture(Picture picture);

    /**
     * 删除图片
     * @param id 删除请求id
     * @param request 请求
     * @return 是否删除成功
     */
    Boolean deletePicture(long id, HttpServletRequest request);

    /**
     * 更新图片（仅管理员可用）
     * @param updateRequest 更新请求
     * @return 是否更新成功
     */
    Boolean updatePicture(PictureUpdateRequest updateRequest, HttpServletRequest request);

    /**
     * 审核图片(仅管理员)
     * @param photoReviewRequest 审核请求
     * @param loginUser 登录用户
     */
    void doPictureReview(PictureReviewRequest photoReviewRequest, User loginUser);

    /**
     * 填充审核参数
     */
    void fillReviewParams(Picture picture, User loginUser);

    /**
     * 点赞图片
     *
     * @param pictureLikeRequest 点赞请求
     * @return 是否点赞成功
     */
    Boolean likePicture(PictureLikeRequest pictureLikeRequest);

    /**
     * 批量抓取和创建图片
     *
     * @param pictureUploadByBatchRequest 批量上传图片请求
     * @param loginUser 登录用户
     * @return 成功创建的图片数
     */
    Integer uploadPictureByBatch(PictureUploadByBatchRequest pictureUploadByBatchRequest, User loginUser);

    /**
     * 批量修改图片信息
     * @param pictureEditByBatchRequest 图片批量修改请求
     * @param loginUser 登录用户
     */
    void editPictureByBatch(PictureEditByBatchRequest pictureEditByBatchRequest, User loginUser);

    /**
     * AI 扩展图片服务
     *
     * @param createPictureOutPaintingTaskRequest 扩展图片请求
     * @param loginUser 登录的用户
     * @return 扩展图片响应
     */
    CreateOutPaintingTaskResponse createPictureOutPaintingTask(CreatePictureOutPaintingTaskRequest createPictureOutPaintingTaskRequest, User loginUser);


    Page<PictureVO> getLikedPictures(List<Long> pictureIds, long current, long size);

    void checkPictureAuth(User loginUser, Picture picture);
}
